//
//  YSTabBarController.m
//  YSEmoticonKeyboard
//
//  Created by MOLBASE on 2017/12/20.
//  Copyright © 2017年 YangShen. All rights reserved.
//

#import "YSTabBarController.h"
#import "YSMessageViewController.h"
#import "YSFriendsViewController.h"

@interface YSTabBarController ()

@end

@implementation YSTabBarController

+ (void)initialize {
    // 设置NavBar
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_background"] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setTranslucent:YES];
    [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
    // 设置Tabbar字体
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor grayColor],NSFontAttributeName : [UIFont systemFontOfSize:12]} forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor orangeColor], NSFontAttributeName : [UIFont systemFontOfSize:12]} forState:UIControlStateSelected];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addViewControllers];
}

- (void)addViewControllers {
    [self addChildViewControllerWithTitle:@"消息" imageName:@"message_nor" selectedImageName:@"message_nor" className:@"YSMessageViewController"];
    [self addChildViewControllerWithTitle:@"通讯录" imageName:@"friends_nor" selectedImageName:@"friends_sel" className:@"YSFriendsViewController"];
}

- (void)addChildViewControllerWithTitle:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName className:(NSString *)className {
    UIViewController *vc = [[NSClassFromString(className) alloc] init];
    vc.view.backgroundColor = [UIColor whiteColor];
    vc.title = title;
    UINavigationController *navc = [[UINavigationController alloc] initWithRootViewController:vc];
    navc.tabBarItem.image = [UIImage imageNamed:imageName];
    navc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
    [self addChildViewController:navc];
}

@end
